'''
Created on 21 juil. 2010

@author: laurent
'''

class SynchronizedMethod:
    def __init__(self, lock, orig):
        self.lock = lock
        self.orig = orig
    def __call__(self, *l):
        self.lock.acquire()
        try:
            r = self.orig(*l)
        finally:
            self.lock.release()
            pass
        return r